package com.listen;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;

@Slf4j
@Component
public class TopicListen {
    @JmsListener(destination = "${my-topic}")
    public void listen(Message message) {
        try {
            log.info("接受消息：" + ((TextMessage) message).getText());
        } catch (JMSException e) {
            log.error("出错", e);
        }
    }
}
